package cn.tedu.spring.di;

import cn.tedu.spring.di.UserDao;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zq
 * @version 1.0
 * @create 2024-08-02 11:24
 * @since jdk1.8
 */
public class TestUserDao {
    public static void main(String[] args) {
        // 创建IOC容器
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext("cn.tedu.spring.di");
        // 获取bean
        UserDao userDao = context.getBean(UserDao.class);
        System.out.println(userDao);
        UserService bean = context.getBean(UserService.class);
        System.out.println(bean);

        //使用xml配置文件创建IOC容器
//        ClassPathXmlApplicationContext context1 =
//                new ClassPathXmlApplicationContext("application.xml");
//        UserDao userDao1 = context1.getBean(UserDao.class);
//        System.out.println(userDao1);

    }

}
